package com.songlanyun.common.enums;

import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson.parser.deserializer.EnumDeserializer;
import com.alibaba.fastjson.serializer.EnumSerializer;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;
import com.songlanyun.common.utils.DateUtils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;

/**
 * 订单的相关枚举
 */
public class OrderConstant {


    /**
     * 运费计算方式
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum FreightComputeMode implements IntegerEnum<Integer> {
        ITEM(0, "按件"),
        WEIGHT(1, "按重量"),
        BULK(2, "按体积");


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        FreightComputeMode(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static FreightComputeMode getByCode(int code) {
            for (FreightComputeMode value : FreightComputeMode.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 运费计算的策略
     */
    public enum FreightStrategy implements IntegerEnum<Integer> {

        SUPERIMPOSED(0, "订单总运费为各个商品运费之和"),
        HIGHEST(1, "订单总运费为运费最高商品运费"),
        LOWEST(2, "订单总运费为运费最低的商品运费");

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        FreightStrategy(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static FreightStrategy getByCode(int code) {
            for (FreightStrategy value : FreightStrategy.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 自提订单运费计算的策略
     */
    public enum ExpiredOrderHandleMode implements IntegerEnum<Integer> {

        //过期后，订单将自动完成，不退款
        COMPLETE_NO_REFUND(0, "订单将自动完成，不退款"),

        //过期后，订单将自动维权，自动向买家退款
        AUTO_RIGHTS_REFUND(1, "自动维权,自动退款");

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        ExpiredOrderHandleMode(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ExpiredOrderHandleMode getByCode(int code) {
            for (ExpiredOrderHandleMode value : ExpiredOrderHandleMode.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 支付方式（0余额，1微信，2支付宝,3银行线下,4现金支付,5积分支付,6积分+余额支付,7积分+微信支付,8积分+支付宝支付）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum PayMode implements IntegerEnum<Integer> {
        //0余额，1微信，2支付宝
        BALANCE(0, "余额"),
        WE_CHAT(1, "微信"),
        ALIPAY(2, "支付宝"),
        BANK(3, "银行线下"),
        READY_UP(4, "现金支付"),
        POINT(5, "积分支付"),
        POINT_BALANCE(6, "积分+余额支付"),
        POINT_WE_CHAT(7, "积分+微信支付"),
        POINT_ALIPAY(8, "积分+支付宝支付"),
        WELFARE_INTEGRAL(9, "公益积分"),
        ALIPAY_HUIFU(10,"支付宝（汇付）"),
        POINT_ALIPAY_HUIFU(11, "积分+支付宝（汇付）"),

        ALIPAY_HSQ(12, "支付宝（慧收钱）"),
        POINT_ALIPAY_HSQ(13, "积分+支付宝（慧收钱）"),

        KJ(14, "快捷支付"),
        POINT_KJ(15, "积分+快捷支付"),
        QUICK_PAY_ALIPAY(16, "快钱支付宝支付"),
        QUICK_PAY_AWE_CHAT(17, "快钱微信支付"),
        QUICK_PAY(18, "快钱支付"),
        VOUCHER_PAY(19, "兑换券支付"),
        QUICK_PAY_BANK(20, "快钱快捷支付"),
        ADMIN_ORDER(21, "后台订单"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        PayMode(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static PayMode getByCode(int code) {
            for (PayMode value : PayMode.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 0系统自动,1 微信小程序，2 APP（订单来源）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum ChannelType implements IntegerEnum<Integer> {
        //0系统自动,1 微信小程序，2 APP（订单来源）
        SYSTEM(0, "系统"),
        WE_APPLET(1, "微信小程序"),
        APP(2, "APP");


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        ChannelType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ChannelType getByCode(int code) {
            for (ChannelType value : ChannelType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 交易状态（0已下单,待支付，1待发货（待备货），2,"部分发货",3,"待收货（待自提（自提订单）,待使用（服务订单））"，4,"部分收货（部分使用（服务订单）",5交易完成,6关闭
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum TransactionStatus implements IntegerEnum<Integer> {
        //已下单,待支付
        WAIT_PAYMENT(0, "已下单,待支付"),

        //待发货（待备货）
        WAIT_SHIP(1, "待发货（待备货"),

        //只有子订单才有部分发货（部分备货）（1、至少一个子订单待收货（已发货），同时存在待发货的其它子订单）
        //当一个子订单未发货，同时另外的子订单或包裹已收货时 主订单状态还是部分发货
        PART_SHIP(2, "部分发货"),

        //待收货（待自提）
        // 1、所有子订单都是待收货主订单才算待收货
        // 2、至少一个子订单待收货，其它子订单为交易关闭，也算待收货，否则为部分发货）
        WAIT_RECEIPT(3, "待收货（待自提（自提订单）,待使用（服务订单））"),

        //只有子订单才有部分收货(1、至少一个子订单交易完成,同时其它子订单还是待收货或PART_RECEIPT)
        PART_RECEIPT(4, "部分收货（待使用（服务订单））"),

        //交易完成（1、所有子订单关易交易完成才算完成，2、至少一个子订单交易完成，其它子订单为交易关闭或进入退货状态，才交易完成）
        COMPLETE(5, "交易完成"),

        //交易关闭
        // 1、所有子订单交易关闭才算关闭
        // 2、支付后订单退款完成
        // 3、下单后用户取消订单
        CLOSE(6, "交易关闭");


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        TransactionStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static TransactionStatus getByCode(int code) {
            for (TransactionStatus value : TransactionStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 0未发货，1部分发货，2已发货
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum ShipStatus implements IntegerEnum<Integer> {

        /**
         * 未发货(未备货)
         */
        NO_SHIP(0, "未发货(未备货)"),
        /**
         * 部分已发货（部分已备货）
         */
        PART_SHIP(1, "部分已发货（部分已备货）"),
        /**
         * 已发货（已完成备货）
         */
        ALREADY_SHIP(2, "已发货（已完成备货）");


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        ShipStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ShipStatus getByCode(int code) {
            for (ShipStatus value : ShipStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 0未使用，1部分已使用，2已全部使用
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum UseStatus implements IntegerEnum<Integer> {

        /**
         * 0未使用
         */
        NO_USE(0, "未使用"),
        /**
         * 部分已发货（部分已备货）
         */
        PART_USE(1, "部分已使用"),
        /**
         * 已全部使用
         */
        ALL_USE(2, "已全部使用");


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        UseStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static UseStatus getByCode(int code) {
            for (UseStatus value : UseStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 0，未收货，1部分收货，2已收货
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum ReceiptStatus implements IntegerEnum<Integer> {

        NO(0, "未收货"),

        PART(1, "部分已收货"),

        COMPLETE(2, "已收货");


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        ReceiptStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ReceiptStatus getByCode(int code) {
            for (ReceiptStatus value : ReceiptStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 0用户未评，1用户部分已评，2全部已评
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum CommentStatus implements IntegerEnum<Integer> {

        NO(0, "用户未评"),

        PART(1, "部分收货"),

        COMPLETE(2, "全部已评");


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        CommentStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static CommentStatus getByCode(int code) {
            for (CommentStatus value : CommentStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 订单的维权状态（0没有，1维权中，2完成,3失败）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum RightsStatus implements IntegerEnum<Integer> {

        NO(0, "没有"),

        BEING(1, "维权中"),

        COMPLETE(2, "完成"),

        FAIL(3, "失败");


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        RightsStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static RightsStatus getByCode(int code) {
            for (RightsStatus value : RightsStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 出货方式（0物流，1自提，2预约）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum ShipmentMode implements IntegerEnum<Integer> {
        EXPRESS(0, "快递"),
        PICK_UP(1, "自提"),
        APPOINTMENT(2, "预约");

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        ShipmentMode(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ShipmentMode getByCode(int code) {
            for (ShipmentMode value : ShipmentMode.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 订单的维权类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum RightsType implements IntegerEnum<Integer> {

        NO(0, "没有"),

        REFUND(1, "退款"),

        RETURN(2, "退货退款");


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        RightsType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static RightsType getByCode(int code) {
            for (RightsType value : RightsType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 0未支付 1支付成功，但业务发生异常需要发起退款 2支付成功，但业务发生异常自款成功 3支付成功，但业务发生异常退款失败 4支付失败 5已支付(已支付成功),6支付过期
     */
//    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum PaymentStatus implements IntegerEnum<Integer> {

        /**
         * 0未支付 1支付成功，但业务发生异常需要发起退款 2支付成功，但业务发生异常自款成功 3支付成功，但业务发生异常退款失败 4支付失败 5已支付(已支付成功)
         */
        NO_PAY(0, "未支付"),

        /**
         * 支付成功，但业务发生异常需要发起退款
         */
        SUCCESS_BUSINESS_ERROR_LAUNCH_REFUND(1, "支付成功，但业务发生异常需要发起退款"),
        /**
         * 支付成功，但业务发生异常自款成功
         */
        SUCCESS_BUSINESS_ERROR_REFUND_SUCCESS(2, "支付成功，但业务发生异常退款成功"),
        /**
         * 支付成功，但业务发生异常退款失败
         */
        SUCCESS_BUSINESS_ERROR_REFUND_FAIL(3, "支付成功，但业务发生异常退款失败"),
        /**
         * 支付失败
         */
        FAIL(4, "支付失败"),

        /**
         * 已支付(已支付成功)
         */
        SUCCESS(5, "已支付(已支付成功)"),
        /**
         * 支付过期
         */
        EXPIRE(6, "支付过期");


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        PaymentStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static PaymentStatus getByCode(int code) {
            for (PaymentStatus value : PaymentStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 订单关闭原因
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum CloseMode implements IntegerEnum<Integer> {

        //未关闭
        NO(0, "未关闭"),

        //用户撤销关闭
        USER_CANCEL(1, "用户撤销关闭"),

        //商家撤销关闭
        BUSINESS_CANCEL(2, "商家撤销关闭"),

        //支付过期关闭
        PAY_EXPIRE(3, "支付过期关闭"),

        //退款成功信息
        REFUND_SUCCESS(4, "退款成功"),

        //支付成功,但条件已经不允许购买,发生自动退款关闭
        PAY_SUCCESS_CONDITION_REFUND(5, "支付成功,但条件已经不允许购买,发生自动退款关闭"),
        //自提过期
        PICKUP_EXPIRE(6, "自提过期"),

        THIRD_PAY_FAIL(7, "第三方支付系统提示支付失败");


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        CloseMode(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static CloseMode getByCode(int code) {
            for (CloseMode value : CloseMode.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 订单类型
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum OrderType implements IntegerEnum<Integer> {

        REFILL_ORDER(0, "转入订单"),
        SALE_ORDER(1, "消费订单"),
        SERVICE_ORDER(2, "服务订单"),

        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        OrderType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static OrderType getByCode(int code) {
            for (OrderType value : OrderType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 0下单减库存，1支付减库存
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum StockDeductMode implements IntegerEnum<Integer> {

        //未关闭
        ORDER(0, "下单减库存"),

        //用户撤销关闭
        PAY(1, "支付减库存"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        StockDeductMode(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static StockDeductMode getByCode(int code) {
            for (StockDeductMode value : StockDeductMode.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 0物流包裹，1自提包裹
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum GoodsPackageType implements IntegerEnum<Integer> {

        //物流包裹
        EXPRESS(0, "物流包裹"),

        //自提包裹
        PICKUP(1, "自提包裹"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        GoodsPackageType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static GoodsPackageType getByCode(int code) {
            for (GoodsPackageType value : GoodsPackageType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 0等待收货，1已收货，2过期
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum GoodsPackageStatus implements IntegerEnum<Integer> {

        WAIT_RECEIPT(0, "等待收货"),
        RECEIPTED(1, "已收货"),
        EXPIRE(2, "收货过期"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        GoodsPackageStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static GoodsPackageStatus getByCode(int code) {
            for (GoodsPackageStatus value : GoodsPackageStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 0无，1商家管理员，2系统自动核销(过期自动核销）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum VerificationRole implements IntegerEnum<Integer> {

        NO(0, "未核销"),
        Admin(1, "商家管理员"),
        SYSTEM(2, "系统自动核销(过期自动核销）"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        VerificationRole(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static VerificationRole getByCode(int code) {
            for (VerificationRole value : VerificationRole.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 0建团中（团长还没有支付），1建团成功，成团中（团长支付完成），2组团完成，3建团失败（团长未支付）4组团失败（时间到了人员不足）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum TeamStatus implements IntegerEnum<Integer> {

        CREATING(0, "建团中（团长还没有支付)"),
        CREAT_SUCCESS(1, "建团成功，成团中（团长支付完成）"),
        TEAM_SUCCESS(2, "2组团完成"),
        CREAT_FAIL(3, "建团失败（团长未支付"),
        TEAM_FAIL(4, "组团失败（时间到了人员不足"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        TeamStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static TeamStatus getByCode(int code) {
            for (TeamStatus value : TeamStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 0没有维权，1团过期自动维权退款，2成团后的会员维权
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum MemberRightsType implements IntegerEnum<Integer> {

        NO(0, "0没有维权"),
        COMPOSE_EXPIRE(1, "团过期自动维权退款"),
        COMPOSED_USER_APPLY(2, "成团后的会员维权"),

        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        MemberRightsType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static MemberRightsType getByCode(int code) {
            for (MemberRightsType value : MemberRightsType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 订单状态
     * 订单未完成
     * 订单已完成，未结算
     * 订单已结算
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum OrderStatus implements IntegerEnum<Integer> {

        /**
         * 未发货(未备货)
         */
        ORDER_NOT_COMPLETED(0, "订单未完成"),
        /**
         * 部分已发货（部分已备货）
         */
        ORDER_OUTSTANDING(1, "订单已完成，未结算"),
        /**
         * 已发货（已完成备货）
         */
        ORDER_SETTLED(2, "订单已结算");

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        OrderStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static OrderStatus getByCode(int code) {
            for (OrderStatus value : OrderStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 服务订单的使用状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum ServiceGoodsUseStatus implements IntegerEnum<Integer> {

        /**
         * 可使用
         */
        ABLE_USE(0, "可使用"),
        /**
         * 已过期
         */
        EXPIRED(1, "已过期"),
        /**
         * 已完成
         */
        COMPLETE(2, "已完成"),

        /**
         * 未支付，不可用
         */
        NOT_USE(4, "未支付，不可用");

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        ServiceGoodsUseStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ServiceGoodsUseStatus getByCode(int code) {
            for (ServiceGoodsUseStatus value : ServiceGoodsUseStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * * 物流状态
     * * 0：已发货
     * * 1：已收货
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum LogisticsStatus implements IntegerEnum<Integer> {

        /**
         *
         */
        SHIPPED(0, "已发货"),
        /**
         *
         */
        RECEIVED(1, "已收货"),
   ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        LogisticsStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static LogisticsStatus getByCode(int code) {
            for (LogisticsStatus value : LogisticsStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * * 0：普通订单
     * * 1：加盟订单
     * * 2：集采订单
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum UserOrderGainsType implements IntegerEnum<Integer> {

        /**
         *
         */
        GENERAL(0, "普通订单"),
        /**
         *
         */
        ALLIANCE(1, "加盟订单"),
        /**
         *
         */
        CENTRAL_PURCHASING(2, "集采订单"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        UserOrderGainsType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static UserOrderGainsType getByCode(int code) {
            for (UserOrderGainsType value : UserOrderGainsType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 获得明天加多少天数的时间戳
     *
     * @param currentTime
     * @param day
     * @return
     */
    public static long getTomorrowAndDayTimestamp(long currentTime, int day) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String date = format.format(currentTime).concat(" 23:59:59");
        Date translateDate = DateUtils.stringToDate(date, DateUtils.DATE_TIME_PATTERN);
        translateDate = DateUtils.addDateDays(translateDate, day);
        return translateDate.getTime();
    }


}
